<?php
include_once("class-registerable-course.php");
    class TrainningItem {
        var $trnpItemId;
        var $studySemester;
        var $sylabusLink;
		var $course;
		var $trnpProgramId;
        
    function __construct(){}
    
    function getTrnpItemId(){
        return $this->trnpItemId;
    }
    function setTrnpItemId($newTrnpItemId){
        $this->trnpItemId = $newTrnpItemId;
    }  
    function getStudySemester(){
        return $this->studySemester;
    }
     function setStudySemester($newStudySemester){
        $this->studySemester = $newStudySemester;
    }
     function getSylabusLink(){
        return $this->sylabusLink;
    }
    function setSylabusLink($newSylabusLink){
        $this->sylabusLink = $newSylabusLink;
    } 
	
	function getCourse(){
        return $this->course;
    }
    function setCourse($newCourse){
        $this->course = $newCourse;
    }
	
	function getTrnpProgramId(){
        return $this->trnpItemId;
    }
    function setTrnpProgramId($newTrnpItemId){
        $this->trnpItemId = $newTrnpItemId;
    }
	
    function addTrainningItem($idtrainningpro,$checkid,$semester,$trnp){
        $sql = "INSERT INTO `trainningitem` (TRNP_ID,COURSE_ID,STUDY_SEMESTER) VALUES('".$idtrainningpro."','".$checkid."',".$semester.")";
        mysql_query($sql);
    }
    
	function listTrnpItemInProgram($programID,$semester,$registeredCourseID) {
		$sql = "SELECT * FROM `trainningitem`, `course`  WHERE `TRNP_ID` LIKE '".$programID."' AND `STUDY_SEMESTER` = ".$semester." AND `course`.`COURSE_ID` = `trainningitem`.`COURSE_ID`";
		$query = mysql_query($sql); 

		$list = array();
		while($row=mysql_fetch_array($query)) { 
			$temp = new RegisterableCourse;
			$temp->setAll($row["COURSE_ID"],$row["COURSE_NAME"],$row["COURSE_CREDIT"],$row["SYLLABUS"],$row["STUDY_SEMESTER"]);
			
			if(!in_array($temp->getCourseID(), $registeredCourseID)) {
				$list[] = $temp;
			}
		}
		return $list;
	}
	
	function listTrnpItemInProgramAll($programID,$registeredCourseID) {
		$sql = "SELECT * FROM `trainningitem`, `course`  WHERE `TRNP_ID` LIKE '".$programID."' AND `course`.`COURSE_ID` = `trainningitem`.`COURSE_ID`";
		$query = mysql_query($sql); 

		$list = array();
		while($row=mysql_fetch_array($query)) { 
			$temp = new RegisterableCourse;
			$temp->setAll($row["COURSE_ID"],$row["COURSE_NAME"],$row["COURSE_CREDIT"],$row["SYLLABUS"],$row["STUDY_SEMESTER"]);
			
			if(!in_array($temp->getCourseID(), $registeredCourseID)) {
				$list[] = $temp;
			}
		}
		return $list;
	}
}
?>